home *** CD-ROM | disk | FTP | other *** search
/ 3D Images / 3D Images.iso / programs / amiga / 2view / source / misc.c < prev   
C/C++ Source or Header  |  1995-01-12  |  17KB  |  672 lines

  1.  
  2. #include <exec/types.h>
  3. #include <dos/rdargs.h>
  4. #include <devices/printer.h>
  5. #include <devices/prtgfx.h>
  6. #include <intuition/screens.h>
  7. #include <intuition/intuition.h>
  8. #include <exec/memory.h>
  9. #include <dos/dos.h>
  10.  
  11. #include <graphics/gfxmacros.h>
  12. #include <graphics/copper.h>
  13. #include <hardware/custom.h>
  14.  
  15. #include <workbench/startup.h>
  16.  
  17. #include "iff.h"
  18. #include "2View.h"
  19. #include "arexx.h"
  20.  
  21. /*Prototypes*/
  22. #include <clib/exec_protos.h>
  23. #include <clib/intuition_protos.h>
  24. #include <clib/graphics_protos.h>
  25. #include <clib/iffparse_protos.h>
  26. #include <clib/dos_protos.h>
  27. #include <clib/alib_protos.h>
  28.  
  29. /*Pragmas*/
  30. #include <pragmas/exec_pragmas.h>
  31. #include <pragmas/intuition_pragmas.h>
  32. #include <pragmas/graphics_pragmas.h>
  33. #include <pragmas/iffparse_pragmas.h>
  34. #include <pragmas/dos_pragmas.h>
  35.  
  36. BPTR StdErr=NULL;   /*'Standard error' for AmigaDOS IO functions*/
  37.  
  38. /*These are defined in 2View.c, but this file needs to reference them*/
  39.  
  40. extern struct NewScreen newScreen;
  41. extern struct NewWindow newWindow;
  42.  
  43. extern struct IFFHandle *iff;    /*IFF handle*/
  44. extern BPTR pL;         /*Playlist file pointer*/
  45. extern BOOL masking,print,toFront,printPics;
  46.  
  47. /*A true here indicates the current ILBM file is compressed*/
  48. extern BYTE Compression;
  49.  
  50. extern char trashBuf[512];     /* A place to dump mask information */
  51.  
  52. extern struct Screen *screen;
  53. extern struct Window *window;
  54.  
  55. /*The previous screen and window*/
  56. extern struct Window *prevWindow;
  57. extern struct Screen *prevScreen;
  58.  
  59. /*Libraries we'll need*/
  60. extern struct Library *IFFParseBase;
  61. extern struct Library *IntuitionBase;
  62. extern struct Library *GfxBase;
  63.  
  64. /*Provided by the compiler*/
  65. extern struct Library *SysBase;
  66. extern struct Library *DOSBase;
  67.  
  68. extern BOOL cycle;
  69. extern UBYTE numColors;
  70. UWORD colorTable[32];
  71. extern UWORD destMap[32];
  72.  
  73. extern struct Custom custom;
  74.  
  75. /*Convert the CMAP information into a color map, then set the colors*/
  76. /*of the screen according to that colormap*/
  77. void setScreenColors(struct Screen *scr, UBYTE *colorMap, UBYTE depth,
  78.              UWORD *destColorMap,UBYTE *colors)
  79. {
  80.    int i,numColors;
  81.  
  82.    numColors=1<<depth;    /*Get the number of colors (generally 2^depth)*/
  83.  
  84.    if(newScreen.ViewModes & HAM)    /*There are, of course, 2 exceptions*/
  85.       numColors=16;
  86.    if(newScreen.ViewModes & EXTRA_HALFBRITE)
  87.       numColors=32;
  88.  
  89.       /*For each color, convert it from CMAP to Amiga form and*/
  90.       /*store it (both in an unchanging table (colorTable) and in a "work" */
  91.       /*table (destColorMap), where the values are free to change during */
  92.       /*color cycling, etc.*/
  93.    for(i=0;i<numColors;i++)
  94.       colorTable[i]=destColorMap[i]=
  95.         (15 & (colorMap[i*3])>>4)<<8 | (15 & (colorMap[i*3+1])>>4)<<4 |
  96.            (15 & (colorMap[i*3+2]>>4));
  97.  
  98.       /*Store the color table*/
  99.    LoadRGB4(&(scr->ViewPort),destColorMap,numColors);
  100.  
  101.       /*Return the number of colors*/
  102.    *colors=numColors;
  103.  
  104.    return;
  105. }
  106.  
  107. /*Make a newScreen structure using the BMHD chunk*/
  108. void getBMHD(struct BitMapHeader *bmhd)
  109. {
  110.                        /*Define the screen as hires if*/
  111.    if(bmhd->PageWidth > 400 && bmhd->PageWidth <=704 && bmhd->nplanes < 5)
  112.       newScreen.ViewModes|=HIRES;      /*wider than 400 pixels and not */
  113.                        /*deeper than 4 bitplanes*/
  114.  
  115.    if(bmhd->PageHeight > 300 && bmhd->PageHeight <=512)  /*Define the screen as interlaced*/
  116.       newScreen.ViewModes|=LACE;       /*if the height is > 300 pixels*/
  117.  
  118.    newScreen.Width=bmhd->w;           /*Store the rest of the values*/
  119.    newScreen.Height=bmhd->h;
  120.  
  121.    newScreen.LeftEdge=bmhd->x;
  122.    newScreen.TopEdge=bmhd->y;
  123.    newScreen.Depth=bmhd->nplanes;
  124.  
  125.    masking=(bmhd->Masking == 1);
  126.  
  127.    Compression=bmhd->Compression;   /*Compression flag.  Store for*/
  128.                     /*later use*/
  129.    return;
  130. }
  131.  
  132. /*Data structures for ReadArgs()*/
  133. struct RDArgs ra=
  134. {
  135.    {NULL,0,0},
  136.    NULL,
  137.    trashBuf,
  138.    512,
  139.    "FILE/A/M,SECS=SECONDS/K/N,TICKS/K/N,LOOP/S,FROM/K,PRINT/S"
  140. };
  141.  
  142. /*Parse the argument list, using ReadArgs()*/
  143. void ParseArgs(ULONG *args)
  144. {
  145.    ReadArgs("FILE/A/M,SECS=SECONDS/K/N,TICKS/K/N,LOOP/S,FROM/K,PRINT/S",
  146.         args,&ra);
  147.    return;
  148. }
  149.  
  150. /*Check to see which mouse buttons have been pressed*/
  151. ButtonTypes checkButton(void)
  152. {
  153.    struct IntuiMessage *mesg;
  154.    ButtonTypes Button=none;
  155.    static justActivated=FALSE;
  156.  
  157.       /*This function disregards a select (left) mouse button click*/
  158.       /*if the window's just been activated.  This is so that a user*/
  159.       /*can click on another window, then make this one active again,*/
  160.       /*without advancing to the next picture*/
  161.  
  162.      /*While there are messages to be read...*/
  163.    while((mesg=(struct IntuiMessage *)GetMsg(prevWindow->UserPort))!=NULL)
  164.    {
  165.      /*Interpret them*/
  166.       switch(mesg->Class)
  167.       {
  168.      case ACTIVEWINDOW:   /*Set the appropriate flag if the window*/
  169.         justActivated=TRUE;  /*was just activated*/
  170.         break;
  171.      case VANILLAKEY:
  172.         switch(mesg->Code)
  173.         {
  174.            case 16:       /*CTRL-P - Print (if this picture hasn't been*/
  175.           if(print)   /*printed;  this is designed in case the user*/
  176.           {          /*holds down CTRL-P: we don't want 10-20     */
  177.                   /*print requests to get queued up        */
  178.              dumpRastPort(&(prevScreen->RastPort),
  179.                   &(prevScreen->ViewPort));
  180.              print=FALSE;
  181.           }
  182.           break;
  183.            case 4:          /*CTRL-D - Abort everything*/
  184.           Button=menu;
  185.           break;
  186.            case 3:
  187.           Button=select; /*CTRL-C - Advance to next picture*/
  188.           break;
  189.            case 9:          /*TAB:  Switch color cycling on/off*/
  190.           toggleCycling();
  191.           break;
  192.  
  193.         }
  194.         break;
  195.      case MOUSEBUTTONS:   /*Interpret a button click*/
  196.         if(mesg->Code==SELECTDOWN) /*If the left button was pushed,*/
  197.            if(justActivated)       /*and not so as to activate the*/
  198.            {               /*window, advance to the next*/
  199.           justActivated=FALSE;         /*screen*/
  200.           break;
  201.            }
  202.            else
  203.           Button=select;
  204.         else if(mesg->Code == MENUDOWN)  /*If the right button was*/
  205.            Button=menu;             /*pushed, we'll want to*/
  206.         break;                 /*abort*/
  207.       }
  208.       ReplyMsg((struct Message *)mesg);      /*Reply to the message*/
  209.    }
  210.    return(Button);                           /*Return the results*/
  211. }
  212.  
  213. /*Toggle color cycling on and off*/
  214. void toggleCycling(void)
  215. {
  216.    int c;
  217.  
  218.    cycle=(cycle) ? FALSE : TRUE;    /*Toggle the color cycling lag*/
  219.    LoadRGB4(&(prevScreen->ViewPort),colorTable,numColors);
  220.    for(c=0;c<numColors;c++)
  221.       destMap[c]=colorTable[c];
  222. }
  223.  
  224.  
  225. struct EasyStruct erError2Line =
  226. {
  227.    sizeof(struct EasyStruct),
  228.    0,
  229.    "Program error:  2View",
  230.    "%s\n%s\n%s",
  231.    "Ok"
  232. };
  233.  
  234. struct EasyStruct erError1Line =
  235. {
  236.    sizeof(struct EasyStruct),
  237.    0,
  238.    "Program error:  2View",
  239.    "%s\n%s",
  240.    "Ok"
  241. };
  242.  
  243. /*This prints an error to the console, if we were run from the CLI*/
  244. /*This is done instead of using Output() so as to get around any redirection*/
  245. /*that may be in place (just like the standard C stderr)*/
  246. /*If we can't open a StdErr or 2View was run from Workbench, a requester */
  247. /*is put up*/
  248. void printError(char *error1,char *error2)
  249. {
  250.    if(StdErr==NULL)
  251.       StdErr=Open("CONSOLE:",MODE_OLDFILE);
  252.  
  253.    /* If we can't open StdErr, or Output()==NULL (meaning we're running */
  254.    /* Workbench), put up a requester */
  255.    if(StdErr==NULL || Output()==NULL)
  256.    {
  257.       if(error2==NULL || error2[0]==NULL)
  258.      EasyRequest(NULL,&erError1Line,NULL,error1,"Exiting...");
  259.       else
  260.      EasyRequest(NULL,&erError2Line,NULL,error1,error2,"Exiting...");
  261.    }
  262.    else
  263.    {
  264.       FPuts(StdErr,error1);
  265.       FPuts(StdErr,error2);
  266.       FPuts(StdErr,"\nExiting\n");
  267.    }
  268.    return;
  269. }
  270.  
  271. extern struct Anchor *anchorPath;
  272.  
  273. /*Free allocated resources in anticipation of quitting*/
  274. void cleanup()
  275. {
  276.    if(anchorPath!=NULL)
  277.       FreeMem(anchorPath,sizeof(struct AnchorPath));
  278.  
  279.       /*Close the ARexx port*/
  280.    dnRexxPort();
  281.  
  282.       /*Close the standard-error file if opened*/
  283.    if(StdErr!=NULL)
  284.       Close(StdErr);
  285.  
  286.       /*Close a previous screen and window, if open*/
  287.    if(prevWindow!=NULL)
  288.       CloseWindow(prevWindow);
  289.    if(prevScreen!=NULL)
  290.       CloseScreen(prevScreen);
  291.  
  292.       /*Close a current screen and window, if open*/
  293.    if(window!=NULL)
  294.       CloseWindow(window);
  295.    if(screen!=NULL)
  296.       CloseScreen(screen);
  297.  
  298.    if(iff!=NULL)
  299.       FreeIFF(iff);
  300.  
  301.    if(pL!=NULL)
  302.       Close(pL);
  303.  
  304.    if(IFFParseBase!=NULL)
  305.       CloseLibrary(IFFParseBase);
  306.  
  307.    if(IntuitionBase!=NULL)
  308.       CloseLibrary(IntuitionBase);
  309.  
  310.    if(GfxBase!=NULL)
  311.       CloseLibrary(GfxBase);
  312. }
  313.  
  314. /*Print the specified RastPort (whose ViewPort is pointed to by vp*/
  315. BOOL dumpRastPort(struct RastPort *rp,struct ViewPort *vp)
  316. {
  317.    struct IODRPReq *printerMsg;
  318.    struct MsgPort *printerPort;
  319.    static BOOL ableToPrint=TRUE;
  320.  
  321.    if(ableToPrint)
  322.    {
  323.       ableToPrint=FALSE;
  324.       printerPort=CreatePort("2View.print.port",0);
  325.       if(printerPort!=NULL)
  326.       {
  327.      printerMsg=(struct IORequest *)CreateExtIO(printerPort,
  328.                        (long)sizeof(struct IODRPReq));
  329.  
  330.      if(printerMsg != NULL)
  331.      {
  332.         /*Open the printer device*/
  333.         if(OpenDevice("printer.device",0,printerMsg,0)==0)
  334.         {
  335.            /*Set up the IODRPReq structure*/
  336.            printerMsg->io_Command=PRD_DUMPRPORT;
  337.            printerMsg->io_RastPort=rp;
  338.            printerMsg->io_ColorMap=vp->ColorMap;
  339.            printerMsg->io_Modes=vp->Modes;
  340.            printerMsg->io_SrcX=0;
  341.            printerMsg->io_SrcY=0;
  342.            printerMsg->io_SrcWidth=vp->DWidth;
  343.            printerMsg->io_SrcHeight=vp->DHeight;
  344.            printerMsg->io_Special=SPECIAL_ASPECT|SPECIAL_FULLROWS|
  345.                       SPECIAL_FULLCOLS;
  346.  
  347.            /*Do it*/
  348.            if(DoIO(printerMsg)==0)
  349.           ableToPrint=TRUE;
  350.  
  351.            CloseDevice(printerMsg);
  352.         }
  353.         DeleteExtIO(printerMsg);
  354.      }
  355.      DeletePort(printerPort);
  356.       }
  357.       return(ableToPrint);
  358.    }
  359. }
  360.  
  361. /*Determine which colors to cycle, for a CRNG*/
  362. UBYTE interpretCRNG(UBYTE *cycleTable,CRNG *crng,UBYTE *rate)
  363. {
  364.    UBYTE length=0;
  365.    UBYTE pos,color;
  366.  
  367.       /*If the rate is zero, colors won't cycle anyway, so return 0*/
  368.    if(crng->rate==0)
  369.       return(0);
  370.  
  371.       /*Get the cycle rate*/
  372.    *rate=16384/crng->rate;
  373.  
  374.       /*If the colors are actually suppossed to be cycling...*/
  375.    if(crng->active!=0)
  376.    {
  377.      /*Get the number of colors to cycle*/
  378.       length=crng->high-crng->low+1;
  379.  
  380.      /*If there are colors to cycle*/
  381.       if(length!=0)
  382.      if(crng->active==1)
  383.            /*Forward cycling*/
  384.         for(pos=0,color=crng->low;pos<length;pos++,color++)
  385.            cycleTable[pos]=color;
  386.      else
  387.            /*Backward cycling*/
  388.         for(pos=0,color=crng->high;pos<length;pos++,color--)
  389.            cycleTable[pos]=color;
  390.    }
  391.    return(length);
  392. }
  393.  
  394. UBYTE interpretDRNG(UBYTE *cycleTable,DRNG *drng,UBYTE *rate)
  395. {
  396.    UBYTE pos;
  397.    DIndex *index;
  398.  
  399.       /*Skip past true-color values*/
  400.    index=(DIndex *)((ULONG)drng+sizeof(DRNG)+4*drng->ntrue);
  401.  
  402.       /*Colors won't cycle if rate is zero, so return 0*/
  403.    if(drng->rate==0)
  404.       return(0);
  405.  
  406.    *rate=16384/drng->rate;
  407.  
  408.       /*If flags==0, there is no color cycling, so return*/
  409.    if(drng->flags==0)
  410.       return(0);
  411.  
  412.       /*Get the color registers to cycle*/
  413.    for(pos=0;pos<drng->nregs;pos++)
  414.    {
  415.       cycleTable[pos]=index->index;
  416.       index=(DIndex *)((ULONG)index+sizeof(DIndex));
  417.    }
  418.  
  419.       /*Return the number of colors that are cycling*/
  420.    return(drng->nregs);
  421. }
  422.  
  423. /*Cycle a screen's colors according to the manner specified in cycleTable*/
  424. void cycleColors(UBYTE *cycleTable,UWORD *colorTable,UBYTE length,
  425.          UBYTE numColors)
  426. {
  427.    UWORD tempColor;
  428.    BYTE color;
  429.  
  430.       /*Get the first color in the cycle list*/
  431.    tempColor=colorTable[cycleTable[length-1]];
  432.  
  433.       /*Shift each color in the list to its next place in the color table*/
  434.    for(color=length-2;color>=0;color--)
  435.       colorTable[cycleTable[color+1]]=colorTable[cycleTable[color]];
  436.  
  437.       /*The first color in the list became the last color */
  438.    colorTable[cycleTable[0]]=tempColor;
  439.  
  440.  
  441.    LoadRGB4(&(prevScreen->ViewPort),colorTable,numColors);
  442. }
  443.  
  444. /*Setup the copper list for dynamic hires images (as output by Macro Paint;*/
  445. /*Digi-View dynamic hires images aren't supported yet).*/
  446. void setupDynHires(struct Screen *scr,UWORD *colorBuf)
  447. {
  448.    UBYTE color;
  449.  
  450.       /*Get the first visible line on the screen*/
  451.    UWORD line=(scr->TopEdge < 0) ? -(scr->TopEdge) : 0;
  452.  
  453.    struct UCopList *cl,*oldCl;
  454.  
  455.    LoadRGB4(&(scr->ViewPort),colorBuf,16);
  456.  
  457.    if(line > 10)
  458.       line-=10;
  459.    else
  460.       line=0;
  461.  
  462.       /*Allocate the copper list header*/
  463.    cl=(struct UCopList *)AllocMem(sizeof(struct UCopList),
  464.                   MEMF_PUBLIC|MEMF_CHIP|MEMF_CLEAR);
  465.  
  466.       /*Return if there was no memory*/
  467.    if(cl==NULL)
  468.       return;
  469.  
  470.       /*Initialize the number of  copper list entries */
  471.    CINIT(cl,17*2*scr->Height);
  472.  
  473.       /*If the image is interlaced, only get the colors for every other*/
  474.       /*scan line (if we were to try to setup every scan line, the image*/
  475.       /*wouldn't come out)*/
  476.    if(scr->ViewPort.Modes & LACE)
  477.       for(;line<scr->Height/2;line++)
  478.       {
  479.      CWAIT(cl,(line-1)<<1,112);
  480.  
  481.         /*Macro Paint only changes colors 4-16*/
  482.      for(color=4;color<16;color++)
  483.         CMOVE(cl,custom.color[color],colorBuf[(line<<5)+color]);
  484.       }
  485.    else
  486.       for(;line<scr->Height;line++)
  487.       {
  488.      CWAIT(cl,(line-1),112)
  489.  
  490.      for(color=4;color<16;color++)
  491.         CMOVE(cl,custom.color[color],colorBuf[(line<<4)+color]);
  492.       }
  493.  
  494.       /*Terminate the copper list*/
  495.    CEND(cl);
  496.  
  497.       /*Install the new copper list, storing the previous one (if any)*/
  498.    oldCl=scr->ViewPort.UCopIns;
  499.    scr->ViewPort.UCopIns=cl;
  500.    RethinkDisplay();
  501.  
  502.       /*If there was a previous copper list, free its memory*/
  503.    if(oldCl!=NULL)
  504.    {
  505.       if(oldCl->FirstCopList != NULL)
  506.      FreeCopList(oldCl->FirstCopList);
  507.       FreeMem(oldCl,sizeof(struct UCopList));
  508.    }
  509.  
  510.    return;
  511. }
  512.  
  513. /*Setup the copper list for a SHAM image*/
  514. void setupSHAM(struct Screen *scr,UWORD *sham)
  515. {
  516.    int posInBuf=17;
  517.    UBYTE color;
  518.  
  519.       /*Get the first visible line on the screen*/
  520.    UWORD line=(scr->TopEdge < 0) ? -(scr->TopEdge) : 0;
  521.    struct UCopList *cl,*oldCl;
  522.  
  523.       /*Start at a line before the first visible line
  524.    if(line > 10)
  525.       line-=10;
  526.    else
  527.       line=0;
  528.  
  529.       /*Allocate the memory for the copper list header*/
  530.    cl=(struct UCopList *)AllocMem(sizeof(struct UCopList),
  531.                   MEMF_PUBLIC|MEMF_CHIP|MEMF_CLEAR);
  532.  
  533.    if(cl==NULL)
  534.       return;
  535.  
  536.       /*Skip past the colors for the first line (which are the same */
  537.       /*as the contents of the CMAP chunk*/
  538.    posInBuf+=(16*line);
  539.  
  540.       /*Create the copper list*/
  541.    for(;line<scr->Height;line++)
  542.    {
  543.       CWAIT(cl,line,200)
  544.       for(color=0;color<16;color++)
  545.      CMOVE(cl,custom.color[color],sham[posInBuf++]);
  546.    }
  547.  
  548.       /*Terminate it*/
  549.    CEND(cl);
  550.  
  551.       /*Install it*/
  552.    oldCl=scr->ViewPort.UCopIns;
  553.    scr->ViewPort.UCopIns=cl;
  554.    RethinkDisplay();
  555.  
  556.       /*Free the memory of the old copper list, if one existed*/
  557.    if(oldCl!=NULL)
  558.    {
  559.       if(oldCl->FirstCopList != NULL)
  560.      FreeCopList(oldCl->FirstCopList);
  561.       FreeMem(oldCl,sizeof(struct UCopList));
  562.    }
  563.  
  564.    return;
  565. }
  566.  
  567. extern struct WBStartup *WBenchMsg;
  568. extern char *playListFilename;
  569. extern UWORD ticks;
  570. extern BOOL loop;
  571. extern long arexxSigBit;
  572.  
  573. void openResources(LONG *args,BOOL *playList,char ***filenames)
  574. {
  575.       /*Open the libraries*/
  576.    IFFParseBase=(struct Library *)OpenLibrary("iffparse.library",0L);
  577.    if(IFFParseBase==NULL)
  578.    {
  579.       cleanup();
  580.       exit(50);
  581.    }
  582.  
  583.    IntuitionBase=(struct Library *)OpenLibrary("intuition.library",0L);
  584.    if(IntuitionBase==NULL)
  585.    {
  586.       cleanup();
  587.       exit(75);
  588.    }
  589.  
  590.    GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L);
  591.    if(GfxBase==NULL)
  592.    {
  593.       cleanup();
  594.       exit(85);
  595.    }
  596.  
  597.       /*Get the arguments*/
  598.    if(WBenchMsg==NULL)
  599.    {
  600.       ParseArgs(args);
  601.  
  602.      /*If a playlist filename was provided, store it for later use*/
  603.       if(args[4]!=NULL)
  604.       {
  605.      playListFilename=(char *)args[4];
  606.      *playList=TRUE;
  607.       }
  608.       else  /*Otherwise, read the filenames from the command line*/
  609.      *playList=FALSE;
  610.  
  611.      /*If a time was provided (in ticks), use it*/
  612.       if(args[1]!=NULL)
  613.      ticks=*(ULONG *)args[1]*50;
  614.  
  615.      /*If a time was provided (in seconds), use it (overrides ticks)*/
  616.       if(args[2]!=NULL && *(ULONG *)args[2]!=0)
  617.      ticks=*(ULONG *)args[2];
  618.  
  619.      /*If neither a picture filename, nor a playlist filename, was*/
  620.      /*specified, print an error and exit.*/
  621.       if(args[0]==NULL && !*playList)
  622.       {
  623.      printError("Please enter one or more filenames","");
  624.      cleanup();
  625.      exit(45);
  626.       }
  627.  
  628.      /*Determine if we should print the pictures we display or not*/
  629.       printPics=(args[5]!=NULL);
  630.  
  631.      /*Get the pointer to the list of filename*/
  632.       *filenames=(char **)args[0];
  633.  
  634.      /*Will we loop back to the beginning once we finish displaying all*/
  635.      /*the pictures?*/
  636.       loop=(args[3]!=NULL);
  637.    }
  638.    else
  639.       if(WBenchMsg->sm_NumArgs==1)
  640.       {
  641.      EasyRequest(NULL,&erError1Line,NULL,
  642.              "2View V1.52 (August 30, 1992)",
  643.              "Written by Dave Schreiber");
  644.      cleanup();
  645.      exit(0);
  646.       }
  647.  
  648.  
  649.       /* Initialize the ARexx port */
  650.    arexxSigBit=initRexxPort();
  651.    if(arexxSigBit==0)
  652.    {
  653.       cleanup();
  654.       exit(47);
  655.    }
  656.  
  657.       /*Allocate the IFF structure*/
  658.    iff=AllocIFF();
  659.  
  660.       /*If the allocation failed, abort*/
  661.    if(iff==NULL)
  662.    {
  663.       printError("Couldn't allocate necessary resources","");
  664.       cleanup();
  665.       exit(100);
  666.    }
  667.  
  668.    return;
  669. }
  670.  
  671. /*End of Misc.c*/
  672.